﻿using System;
using System.Web.Mvc;
using System.Web.Routing;

namespace SubForum.Web
{
    public class MvcApplication : System.Web.HttpApplication
    {
        /// <summary>
        /// Registers the routes.
        /// </summary>
        /// <param name="routes">The routes.</param>
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapRoute(
                "Default",                                              // Route name
                "{controller}/{action}/{id}",                           // URL with parameters
                new { controller = "Home", Forum = "Index", id = "" }  // Parameter defaults
                );

            routes.MapRoute(
                "Forum",
                "{action}/{id}/",
                new { controller = "Forum", action = "Index", id = "" });

            routes.MapRoute(
                "ForumByUser",
                "{controller}/{action}/{user}/{slug}",
                new { controller = "Forum", action = "UserPosts", user = "", slug = "" });
        }

        /// <summary>
        /// Application start.
        /// </summary>
        protected void Application_Start()
        {
            RegisterRoutes(RouteTable.Routes);
        }
    }
}